#ifndef __SPI_BSP_H__
#define __SPI_BSP_H__

#include "spi.h"
#include "FreeRTOS.h"
#include "semphr.h"   
#include "stream_buffer.h"

#define SPI1_OBJ_EN
#define xSPI2_OBJ_EN
#define SPI3_OBJ_EN

typedef enum
{
#ifdef SPI1_OBJ_EN
  SPI1_OBJ,
#endif
#ifdef SPI2_OBJ_EN
  SPI2_OBJ,
#endif
#ifdef SPI3_OBJ_EN
  SPI3_OBJ,
#endif
  SPI_OBJ_NUM_MAX
}spi_obj_id_t;

typedef struct _spi_obj
{
  SPI_HandleTypeDef  *hspi;
  SemaphoreHandle_t mutex;
}spi_obj_t;

void spi_obj_close(spi_obj_id_t obj_id);
int spi_obj_open(spi_obj_id_t obj_id , uint8_t CLKIdleState);
int spi_obj_read(spi_obj_id_t obj_id, uint8_t *buf, int size);
int spi_obj_write(spi_obj_id_t obj_id, uint8_t *buf, int size);

#endif
